package cn.market.web.action.ad;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import org.springframework.stereotype.Controller;

import cn.market.service.ad.AdvertisementService;
import cn.market.utils.Log;
import cn.market.web.formbean.ad.AdvertisementForm;
@Controller("/index/ad/switch")
public class AdvertisementSwitchAction extends DispatchAction {
	private String TAG = "AdvertisementSwitchAction";
	@Resource
	private AdvertisementService advertisementService;
	public ActionForward getAdd(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		String methodName = "getAdd()";
		Log.println(TAG, methodName);
		AdvertisementForm formbean = (AdvertisementForm) form;
		if(formbean.getModulId() != null && formbean.getModulId()>0){
			String content = advertisementService.getAddContentByHtmlModuleId(formbean.getModulId());
			request.setAttribute("content", content);
		}
		return mapping.findForward("add_index");
	}
}
